<template>
  <div class="tableContent" :style="{width:'100%',height:tableHeight+'px'}" >
       <!-- 查询 -->
        <el-popover placement="bottom-start" width="1018" style="box-shadow: 0 0 8px rgba(0,0,0,.5);" trigger="click">
            <el-form :inline="true" :model="tableData.search" class="demo-ruleForm">
                <el-form-item label="护士姓名" style="margin-bottom: 0;">
                    <el-select  v-model="tableData.search.nurseName" value-key="tableData.search.nurseId" style="width: 100px;">
                        <el-option value="" label="【空】"></el-option>
                        <el-option  v-for="item in cache.search.nurseData" :key="item.id" :value="item.name" :label="item.name"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="浆员姓名" style="margin-bottom: 0;">
                        <el-input v-model="tableData.search.providerName" style="width: 100px;"></el-input>
                </el-form-item>
                <el-form-item label="浆员卡号" style="margin-bottom: 0;">
                        <el-input v-model="tableData.search.providerId" style="width: 150px;"></el-input>
                </el-form-item>
                <el-form-item label="浆员活跃等级" style="margin-bottom: 0;">
                    <el-select  v-model="tableData.search.providerActiveLevel" style="width: 220px;">
                        <el-option value="" label="【空】"></el-option>
                        <el-option  v-for="item in cache.search.providerActiveLevelData" :key="item.id" :value="item.code" :label="item.name"></el-option>
                    </el-select>
                </el-form-item>
                <br/>
                <el-form-item label="关联义工" style="margin-top:20px;">
                        <el-input v-model="tableData.search.useVolunteer" style="width: 150px;"></el-input>
                </el-form-item>
                <el-form-item label="浆员地址" style="margin-top: 20px;">
                     <el-input v-model="tableData.search.providerAddress" style="width: 600px;"></el-input>
                </el-form-item>
                <el-button type="primary"  @click="getInitTableXyList" style="float:right;margin-top: 20px;margin-right: 20px;">提交</el-button>
            </el-form>
             <el-button slot="reference" type="primary">查询</el-button>
        </el-popover>
            <el-button  type="primary" style="margin-left:6px;" @click="addButtonEventFun">添加</el-button>
            <el-button  type="primary"     @click="getInitTableXyList" >刷新</el-button>
         <!-- 表格 -->
         <el-table :data="tableData.tbody.rowsData" stripe border class="company-table" style="width: 100%;" :height="tableHeight" v-loading="option.loading">
            <el-table-column prop="linkProviderName" label="浆员姓名" sortable min-width="90"></el-table-column>
            <el-table-column prop="activeLevel" label="浆员活跃等级" sortable min-width="120"></el-table-column>
            <el-table-column prop="createTime" label="创建时间" sortable min-width="120">
                <template slot-scope="scope">
                    <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
                </template>
            </el-table-column>
            <el-table-column prop="address" label="浆员地址" sortable min-width="90"></el-table-column>
            <el-table-column prop="useWeChart" label="是否使用微信" sortable min-width="90"></el-table-column>
            <el-table-column prop="useNurseName" label="护士姓名" sortable min-width="90"></el-table-column>
            <el-table-column prop="useVolunteeName" label="关联义工" sortable min-width="90"></el-table-column>
            <el-table-column prop="useIntroducerName" label="介绍人" sortable min-width="90"></el-table-column>
            <el-table-column prop="totalPulpingCount" label="总献浆量" sortable min-width="90"></el-table-column>
            <el-table-column prop="lastYearPulpingCount" label="去年献浆量" sortable min-width="90"></el-table-column>
            <el-table-column prop="currentYearPulpingCount" label="今年献浆量" sortable min-width="90"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" min-width="75">
                <template slot-scope="scope">
                    <el-button  @click="editButtonEventFun('edit',scope.row)" type="text" size="small">编辑</el-button>
                    <el-button  @click="updateHistoryButtonEventFun('edit',scope.row)" type="text" size="small">修改历史</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="xyLinkSizeChange" @current-change="xyLinkCurrentChange" :current-page="tableData.pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="tableData.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableData.pagination.total"></el-pagination>    
       <!-- dialog弹窗定义 -->
       <el-dialog  :title="dialog.config.title" :visible.sync="dialog.config.isShow"  width="1000px" top="60px" :close-on-click-modal="false"  v-dialogDrag>
            <div :style="dialog.height">
                   <el-form  :inline="true" :model="form.dialog" label-width="100px" class="demo-ruleForm" @submit.native.prevent>
                    <h3  class="dialog-plate-title"><span>配置信息</span></h3>
                         <el-form-item label="护士姓名">
                             <el-select  v-model="form.dialog.nurse" value-key="id"  style="width: 200px;">
                                <el-option  v-for="item in cache.search.nurseData" :key="item.id"  :value="item" :label="item.name"></el-option>
                             </el-select>
                         </el-form-item>
                         <el-form-item label="浆员姓名" >
                             <el-input v-model="form.dialog.linkProviderName" style="width:180px;">
                             <el-button slot="append" icon="el-icon-search" @click="innerDialogShow('provider')"></el-button>
                             </el-input>
                         </el-form-item>
                         <br/>
                         <el-form-item label="创建时间"><el-input v-model="form.dialog.createTime" disabled></el-input></el-form-item>
                         <el-form-item label="浆员现居地址"><el-input v-model="form.dialog.address" style="width: 200px;"></el-input></el-form-item>
                         <br/>
                         <el-form-item label="是否使用微信">
                                <el-select  v-model="form.dialog.useWeChart" style="width: 200px;">
                                     <el-option value="否" label="否"></el-option>
                                     <el-option value="是" label="是"></el-option>
                                </el-select>
                         </el-form-item>
                         <el-form-item label="献浆提醒">
                                <el-select  v-model="form.dialog.isPulpingMsg" style="width: 200px;">
                                     <el-option value="否" label="否" aria-selected="true"></el-option>
                                     <el-option value="是" label="是"></el-option>
                                </el-select>
                         </el-form-item>
                         <br/>
                         <el-form-item label="提醒方式">
                                <el-select  v-model="form.dialog.pulpingMsgType" style="width: 200px;">
                                     <el-option value="按提前天数提醒" label="按提前天数提醒"></el-option>
                                     <el-option value="按间隔天数提醒" label="按间隔天数提醒"></el-option>
                                </el-select>
                         </el-form-item>
                         <el-form-item label="提前提醒天数">
                                <el-select  v-model="form.dialog.advancePulpingMsgDays" style="width: 200px;">
                                     <el-option value="空" label="空" ></el-option>
                                     <el-option value="1天" label="1天"></el-option>
                                     <el-option value="2天" label="2天"></el-option>
                                     <el-option value="3天" label="3天"></el-option>
                                </el-select>
                         </el-form-item>
                         <p style="color:red">提醒方式为提前提醒时默认间隔为14天。设置为间隔提醒时提醒间隔为设定天数且不能小于14天。</p>
                         <br/>
                         <el-form-item label="间隔提醒天数">
                                <el-input v-model="form.dialog.intervalPulpingMsgDays" type="number" onchange="if(value<14)value=14" value="14"
                                ></el-input>
                         </el-form-item>
                           <el-form-item label="浆员活跃等级">
                                <el-select  v-model="form.dialog.activeLevel" style="width: 200px;">
                                    <el-option value="" label="【空】"></el-option>
                                    <el-option  v-for="item in cache.search.providerActiveLevelData" :key="item.id" :value="item.name" :label="item.name"></el-option>                            
                                </el-select>
                         </el-form-item>
                         <br/>
                         <el-form-item label="家人参与献浆"><el-input v-model="form.dialog.familyJoinPulping" style="width: 520px;"></el-input></el-form-item>
                         <br/>
                         <el-form-item label="朋友参与献浆"><el-input v-model="form.dialog.friendJoinPulping" style="width: 520px;"></el-input></el-form-item>
                         <br/>
                         <el-form-item label="关联义工">
                             <el-input v-model="form.dialog.useVolunteeName" style="width: 520px;">
                             <el-button slot="append" icon="el-icon-search" @click="innerDialogShow('voluntter')"></el-button>
                             </el-input>
                         </el-form-item>
                         <br/>
                         <el-form-item label="关联义工时间"><el-input v-model="form.dialog.useVolunteeTime" style="width: 520px;" disabled></el-input></el-form-item>
                   </el-form>
                   <h3  class="dialog-plate-title"><span>浆员信息</span></h3>
                   <pulpworkInfo  :cardid="form.dialog.cardId" :datatype="form.type"></pulpworkInfo>
                   <div>
                    <el-button type="success" @click="submitDialog" style="background-color:#3ac1c4;border: 1px solid #DCDFE6;">提交</el-button>
                   </div>
                   <!-- 内部弹窗dialog,显示选择浆员与义工的弹窗 -->
                          <el-dialog  :title="dialog.inner.config.title" :visible.sync="dialog.inner.config.isShow"   width="1000px" top="60px" :close-on-click-modal="false" append-to-body  v-dialogDrag>
                              <div :style="dialog.inner.height">
                                    <!-- 内部查询框 -->
                                      <!-- 查询 -->
                                    <el-popover placement="bottom-start" width="900" style="box-shadow: 0 0 8px rgba(0,0,0,.5);" trigger="click">
                                        <el-form :inline="true" :model="tableData.inner.search" class="demo-ruleForm">                                         
                                            <el-form-item label="卡号=" style="margin-bottom: 0;">
                                                    <el-input v-model="tableData.inner.search.providerId" style="width: 150px;"></el-input>
                                            </el-form-item>
                                            <el-form-item label="姓名=" style="margin-bottom: 0;">
                                                    <el-input v-model="tableData.inner.search.providerName" style="width: 150px;"></el-input>
                                            </el-form-item>
                                            <el-form-item label="身份证≈" style="margin-bottom: 0;">
                                                    <el-input v-model="tableData.inner.search.providerSFZ" style="width: 150px;"></el-input>
                                            </el-form-item>                          
                                            <el-button type="primary"  @click="getInitInnerTableXyList('all')" style="float:right;margin-top: 20px;margin-right: 20px;">搜索</el-button>
                                            <el-button type="primary"  @click="getInitInnerTableXyList('clear')" style="float:right;margin-top: 20px;margin-right: 20px;">刷新</el-button>
                                        </el-form>
                                        <el-button slot="reference" type="primary">查询</el-button>
                                    </el-popover>
                                            <!-- 内部表格 -->
                                    <el-table  @row-click="fetchRowInfo" :data="tableData.inner.tbody.rowsData" stripe border class="company-table" style="width: 100%;" :height="innerTableHeight" v-loading="option.loading">
                                        <el-table-column prop="头像" label="头像" sortable min-width="30">
                                                 <template slot-scope="scope">
                                                    <img :src="scope.row.photo" style="width: 25px;height:30px">
                                                 </template>
                                        </el-table-column>
                                        <el-table-column prop="cardId" label="卡号" sortable min-width="90"></el-table-column>
                                        <el-table-column prop="name" label="姓名" sortable min-width="90"></el-table-column>
                                        <el-table-column prop="idNo" label="身份证" sortable min-width="180"></el-table-column>
                                        <el-table-column prop="isVolunteer" label="是否义工" sortable min-width="90">
                                             <template slot-scope="scope">
                                                    <div>{{scope.row.isVolunteer == null ? "否" : "是"}}</div>
                                             </template>
                                        </el-table-column>
                                    </el-table> 
                                    <el-pagination background @size-change="xyLinkInnerSizeChange" @current-change="xyLinkInnerCurrentChange" :current-page="tableData.inner.pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="tableData.inner.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableData.inner.pagination.total"></el-pagination>  
                              </div>
                          </el-dialog>
            </div>
       </el-dialog>
       <!-- 护士清单 -->
       <el-dialog  :title="dialog.config.nurseTitle" :visible.sync="dialog.config.isNurseShow"  width="600px" top="60px" :close-on-click-modal="false"  v-dialogDrag>
            <div :style="dialog.nurseHeight">
                                <!-- 内部表格 -->
                                    <el-table   :data="tableData.nurse.tbody.rowsData" stripe border class="company-table" style="width:95%;" :height="nurseTableHeight" v-loading="option.loading">
                                        <el-table-column prop="linkOldNurseName" label="修改前护士" sortable min-width="90"></el-table-column>
                                        <el-table-column prop="linkNewNurseName" label="修改后护士" sortable min-width="90"></el-table-column>
                                        <el-table-column prop="createTime" label="修改时间" sortable min-width="90">
                                              <template slot-scope="scope">
                                                    <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
                                              </template>
                                        </el-table-column>
                                    </el-table> 
                                    <el-pagination background @size-change="xyLinkNurseSizeChange" @current-change="xyLinkNurseCurrentChange" :current-page="tableData.nurse.pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="tableData.nurse.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableData.nurse.pagination.total"></el-pagination>  
            </div>
        </el-dialog>
  </div>
</template>
<script>
import bloodSourcesHttp from 'plugins/axios/bloodSourcesHttp.js';
import api from 'plugins/axios/api.js';
import analysisHttp from 'plugins/axios/analysisHttp.js';
import pulpworkInfo from 'views/operationManage/components/pulpworkInfo.vue';
let obj = {
  components:{
      pulpworkInfo
  },
  data(){
    return {
        option:{
            loading:false,
            isProvider:true
        },
        cache:{
          search:{
              nurseData:[],
              providerData:[],
              volunteerData:[],
              providerActiveLevelData:[],
          },
          //护士缓存数据 方修改历史的时候查看护士修改的问题
          nurse:{
             curName:null,
             oldName:null,
             newName:null
          }
        },
        tableData:{
            search:{
                nurseName:null,
                providerName:null,
                providerActiveLevel:null,
                useVolunteer:null,
                providerAddress:null,
                nurseId:null               
            },
            thead:{},
            tbody:{
                rowsData:[]
            },
            tfooter:{},
            inner:{
                search:{
                         providerId:null,
                         providerName:null,
                         providerSFZ:null            
                       },
                tbody:{
                        rowsData:[]
                    },
                pagination:{
                    currentPage:1,
                    pageSize:10,
                    total:0
                }  
            },
            nurse:{
                search:{
                         providerId:null,
                         providerName:null,
                         providerSFZ:null,
                         linkId:null            
                       },
                tbody:{
                        rowsData:[]
                    },
                pagination:{
                    currentPage:1,
                    pageSize:10,
                    total:0
                }  
            },
            pagination:{
                currentPage:1,
                pageSize:10,
                total:0
            }
        }, 
        tableContent:{
            testData:null
        },
        dialog:{
             //外层弹出框样式
                height: {
                height: document.documentElement.clientHeight - 150+ 'px',
                overflowY: 'auto',
                marginTop: -50+ 'px ',
              },
            //外层弹出框配置项
               config:{
                isShow:false,
                title:'',
                type:'',
                isNurseShow:false,
                nurseTitle:'',
             },
             //外层
               height:{
                    height: document.documentElement.clientHeight - 100+ 'px',
                    overflowY: 'auto',
                    marginTop: -50+ 'px '
             },
             //护士
               nurseHeight:{
                    height: document.documentElement.clientHeight - 350+ 'px',
                    overflowY: 'auto',
                    marginTop: -30+ 'px '
             },
             //内层嵌套dialog配置
                inner:{
                 height:{
                    height: document.documentElement.clientHeight - 100+ 'px',
                    overflowY: 'auto',
                    marginTop: -50+ 'px '
                  },
                 config:{
                    isShow:false,
                    title:'内层弹窗',
                    type:'',
                  }
             }
        },
        form:{
            type:'provider',
            dialog:{
                cardId:null,
                providerId:null,
                useNurseId:null,
                useNurseName:"",
                linkProviderName:null,
                address:null,
                createTime:this.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss'),
                useWeChart:"否",
                isPulpingMsg:"否",
                pulpingMsgType:"按提前天数提醒",
                advancePulpingMsgDays:"空",
                intervalPulpingMsgDays:14,
                activeLevel:"空",           
                familyJoinPulping:"空",           
                friendJoinPulping:"空", 
                useVolunteeId:null,          
                useVolunteeName:"空",
                nurse:{id:""},
                temp:null,           
                useVolunteeTime:this.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss')           
             }
        }
    }
  },
  watch:{
  },
  computed:{
      //外部表格高度
     tableHeight(){
            return this.$store.state.clientHeight-184;
        },
      //内部dialog(弹窗内部)表格高度
    innerTableHeight(){
            return this.$store.state.clientHeight-280;
         },
      //护士配置清单弹窗表格高度
    nurseTableHeight(){
            return this.$store.state.clientHeight-500;
         }
         
  },
  mounted(){
    let self = this;
    //开启加载等待交互界面，避免用户无提示信息体验差
    self.option.loading = true;
    //初始化查询框下拉菜单的option所需后台数据（部分数据来源与用户和角色表）
    self.initCacheData();
    //初始化表格数据
    self.getInitTableXyList();   
  },
  created(){
    window.self = this;    
  },
  methods:{
      syschr(){
          let self = this;
          alert(JSON.stringify(self.form.dialog.nurse));

      },
       //获取血源信息（外部表格信息）
      getInitTableXyList(){
          let self  = this;
          let params={
                currentPage:self.tableData.pagination.currentPage,
                pageSize:self.tableData.pagination.pageSize,
                nurseName:self.tableData.search.nurseName,
                providerName:self.tableData.search.providerName,
                providerActiveLevel:self.tableData.search.providerActiveLevel,
                useVolunteer:self.tableData.search.useVolunteer,
                providerAddress:self.tableData.search.providerAddress                        
          };
          bloodSourcesHttp.getTableXyList(params).then(res=>{
                self.tableData.tbody.rowsData = res.content.items;
                self.tableData.pagination.total = res.content.total;
                self.option.loading = false;
          });
      },
      //获取内部表格信息 人员信息
      getInitInnerTableXyList(type){
          let self  = this;
          if(type==='clear'){
              self.tableData.inner.search.providerId = '';
              self.tableData.inner.search.providerName = '';
              self.tableData.inner.search.providerSFZ  = '';
          }
          if(type==='all'){
              //占无逻辑
          }
          let params={
                currentPage:self.tableData.inner.pagination.currentPage,
                pageSize:self.tableData.inner.pagination.pageSize,
                cardId:self.tableData.inner.search.providerId,
                providerName:self.tableData.inner.search.providerName,
                idNo:self.tableData.inner.search.providerSFZ                       
          };
          //查询用户数据，以供义工、浆员框选择使用
           api.providerInfo(params).then(res=>{
                self.tableData.inner.tbody.rowsData = res.content.records;
                self.tableData.inner.pagination.total = res.content.total;
            },error=>{
                self.option.loading = false;
            })
      },
        //获取护士的信息
      getNurseTableInfo(id){
          let self  = this;
          let params={
                currentPage:self.tableData.nurse.pagination.currentPage,
                pageSize:self.tableData.nurse.pagination.pageSize,
                linkId:id                    
          };
          bloodSourcesHttp.getTableXyListNurseUpdateList(params).then(res=>{
                self.tableData.nurse.tbody.rowsData = res.content.items;
                self.tableData.nurse.pagination.total = res.content.total;
                self.option.loading = false;
          });
      },
       //初始化查询框下拉选项数据
      initCacheData(){
         let self = this;
          //所有护士信息 此处依赖统计模块的查询所有护士接口，如果该处报错或护士信息未查询到，请核对统计模块后端接口是否启动
         analysisHttp.getAllNurse({isCollNurse:false}).then(res=>{
            self.cache.search.nurseData = res.content;
         });
          //浆员活跃等级信息
         bloodSourcesHttp.getProviderActiveLevelCodeByType({type:null}).then(res=>{
                self.cache.search.providerActiveLevelData = res.content;
         });

      },
       //点击外部切换分页(外部)
      xyLinkCurrentChange(currentPage){
            this.tableData.pagination.currentPage=currentPage;
            this.getInitTableXyList()
      },
       // 更改外部每条页面显示数量（外部）
      xyLinkSizeChange(size){
             this.tableData.pagination.pageSize = size;
             this.getInitTableXyList();
      },
       //点击内部切换分页（内部）
      xyLinkInnerCurrentChange(currentPage){
            this.tableData.inner.pagination.currentPage=currentPage;
            this.getInitInnerTableXyList()
      },
       // 更改内部每条页面显示数量（内部）
      xyLinkInnerSizeChange(size){
             this.tableData.inner.pagination.pageSize = size;
             this.getInitInnerTableXyList();
      }, 
       //点击护士配置清单切换分页（）
      xyLinkNurseCurrentChange(currentPage){
            this.tableData.nurse.pagination.currentPage=currentPage;
            this.getNurseTableInfo(this.tableData.nurse.search.linkId)
      },
       // 更改护士配置清单每条页面显示数量（）
      xyLinkNurseSizeChange(size){
             this.tableData.nurse.pagination.pageSize = size;
             this.getNurseTableInfo( this.tableData.nurse.search.linkId);
      },
       // 点击添加按钮弹窗
      addButtonEventFun(){
          let self = this;
          //先清空dialog 表单数据
          self.clearFormData();
          //打开弹窗
          self.dialog.config.isShow = true;
          self.form.type = 'provider';
          //设置弹窗标题
          self.dialog.config.title = "";
          //弹窗共享类型type=inputStore为添加，弹窗控件添加元素的展示，编辑元素的东西退出
          self.dialog.config.type = "inputStore";

      },
      //编辑按钮事件
      editButtonEventFun(type,row){
          debugger;
          let self =  this;
          //self.form.dialog = row;
          self.form.dialog.cardId = row.cardId;  
          self.setDialogRow(row);        
          self.form.type = 'provider';
          self.dialog.config.type = "edit";
          //缓存当前护士名称
          self.cache.nurse.curName = self.form.dialog.useNurseName;
          self.dialog.config.isShow = true;
         

      },
      //获取相关的数据
      setDialogRow(row){
                self.form.dialog.cardId = row.cardId;
                self.form.dialog.providerId = row.linkProviderId;
                self.form.dialog.useNurseId = row.useNurseId;
                self.form.dialog.useNurseName= row.useNurseName;
                self.form.dialog.linkProviderName = row.linkProviderName;
                self.form.dialog.address = row.address;
                self.form.dialog.createTime = row.createTime;
                self.form.dialog.useWeChart = row.useWeChart;
                self.form.dialog.isPulpingMsg = row.isPulpingMsg;
                self.form.dialog.pulpingMsgType =  row.pulpingMsgType;
                self.form.dialog.advancePulpingMsgDays = row.advancePulpingMsgDays;
                self.form.dialog.intervalPulpingMsgDays = row.intervalPulpingMsgDays;
                self.form.dialog.activeLevel = row.activeLevel;       
                self.form.dialog.familyJoinPulping = row.familyJoinPulping;        
                self.form.dialog.friendJoinPulping = row.friendJoinPulping; 
                self.form.dialog.useVolunteeId = row.useVolunteeId;          
                self.form.dialog.useVolunteeName = row.useVolunteeName;
                self.form.dialog.nurse = {id:row.useNurseId};
                self.form.dialog.temp = null,           
                self.form.dialog.useVolunteeTime = row.useVolunteeTime;  
                           
                //后台需要的数据
                self.form.dialog.collectionDate = row.collectionDate;  
                self.form.dialog.currentYearPulpingCount = row.currentYearPulpingCount;  
                self.form.dialog.id = row.id;  
                self.form.dialog.lastYearPulpingCount = row.lastYearPulpingCount;  
                self.form.dialog.linkProviderId = row.linkProviderId;  
                self.form.dialog.linkState = row.linkState;  
                self.form.dialog.nextCollDate = row.nextCollDate;  
                self.form.dialog.remind = row.remind;  
                self.form.dialog.totalPulpingCount = row.totalPulpingCount;  
                self.form.dialog.useIntroducerName = row.useIntroducerName;  
                self.form.dialog.useNurseDeptId = row.useNurseDeptId;  
                self.form.dialog.useNurseTime = row.useNurseTime;  
                self.form.dialog.useWeChart = row.useWeChart;  
      },
      //获取一个dialogRow对象
      getDialogRow(){
            let dialog =  {
                        cardId:null,
                        providerId:null,
                        useNurseId:null,
                        useNurseName:"",
                        linkProviderName:null,
                        address:null,
                        createTime:this.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss'),
                        useWeChart:"否",
                        isPulpingMsg:"否",
                        pulpingMsgType:"按提前天数提醒",
                        advancePulpingMsgDays:"空",
                        intervalPulpingMsgDays:14,
                        activeLevel:"空",           
                        familyJoinPulping:"空",           
                        friendJoinPulping:"空", 
                        useVolunteeId:null,          
                        useVolunteeName:"空",
                        nurse:{id:""},
                        temp:null,           
                        useVolunteeTime:this.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss')           
                 };
        return dialog;
      },
      //获取一个数据对象
      getJsonOb(){
            let jsonOb = {
                address: null,
                allMenus: null,
                birthday: null,
                createTime: 1562135303000,
                deptId: null,
                gender: null,
                id: 2,
                idNo: null,
                menus: null,
                name: "张映兰",
                password: "$2a$10$Aom63m7aHk2fca/YCiY2Iea3fu479tEw9LtJ278aMxPK/cWZr6aiq",
                phone: null,
                photo: "group1/M00/04/26/wKgAj10cvfOAH45HAABqyur1vpY494.jpg",
                postId: null,
                qqNo: null,
                remark: null,
                roles: null,
                telephone: null,
                unitId: 2,
                username: "张映兰",
                wxNo: null
            };
            
            return jsonOb;
      },
      //修改历史按钮事件
      updateHistoryButtonEventFun(type,row){
          let self = this;
          self.dialog.config.isNurseShow = true;
          self.tableData.nurse.search.linkId = row.id;
          self.getNurseTableInfo(row.id);
      },
    
      //打开dialog内嵌人员选择dialog（弹出框）选择浆员或者义工
      innerDialogShow(type){
          let self = this;
          //type 与方法fetchRowInfo()进行逻辑值 self.option.isProvider 判定，判定是否是选择浆员还是义工 同时 innerDialogShow 方法触发点在dialog表单新增血源链接时由 浆员姓名|义工 项点击触发调用
          if(type==='provider'){
             self.option.isProvider = true;
          }else{
             self.option.isProvider = false;
          }
          //打开弹窗
          self.dialog.inner.config.isShow = true;
          //设置弹窗标题
          self.dialog.inner.config.title = "";
          //弹窗共享类型type=inputStore为添加，弹窗控件添加元素的展示，编辑元素的东西退出
          self.dialog.inner.config.type = "userSelect";
          //查询相关数据
          self.getInitInnerTableXyList();
      },
      //提取内部表格行记录，并回显到相关表单数据上面
      fetchRowInfo(row){
          let self = this;
          if(self.option.isProvider){//浆员选择
             self.form.dialog.providerId = row.id; //浆员ID
             self.form.dialog.cardId = row.cardId; //浆员卡号  
             self.form.dialog.linkProviderName = row.name;//浆员姓名
             //临时定义数据
             self.form.dialog.useIntroducerName = row.introducer;//介绍人
             self.form.type = 'provider';//浆员姓名
             self.dialog.inner.config.isShow = false;
          }else{                    //选择义工
             if(row.isVolunteer == null||row.isVolunteer ===""){
                 self.form.dialog.useVolunteeName = row.name;
                 self.form.dialog.useVolunteeId = row.id;   
                 self.dialog.inner.config.isShow = false;
             }else{
                  this.$message({
                    message: '所选人员已是义工',
                    type: 'warning'
                  });
             }
          }        
      },
      //dialog提交，新增血源链接记录
      submitDialog(){
          let self = this;
          //如果是编辑的话就访问编辑的接口
          if(self.dialog.config.type === "edit"){
              self.form.dialog.linkProviderId = self.form.dialog.providerId;
              self.cache.nurse.oldName  = self.cache.nurse.curName;
              self.cache.nurse.newName  = self.form.dialog.nurse.name;
              //进行数据拆分
              self.form.dialog.useNurseDeptId = self.form.dialog.nurse.deptId;//护士部门ID
              self.form.dialog.useNurseName = self.form.dialog.nurse.name;    //护士名称
              self.form.dialog.useNurseId = self.form.dialog.nurse.id;        //护士ID
             //进行编辑数据提交
              bloodSourcesHttp.updateXyLinkInfo(self.form.dialog).then(res=>{
                           if(res.content){
                               //进行form表单数据清空
                               self.clearFormData();
                               //关闭dialog
                               self.dialog.config.isShow = false;
                               //刷新外部表格数据，显示最新添加的血源链接数据
                               self.getInitTableXyList();
                               //进行修改护士清单跟踪 修改前的护士名称与修改后护士名称进行对比
                                if(self.cache.nurse.oldName != self.cache.nurse.newName ){
                                        //组装参数
                                        let param = {
                                            linkOldNurseName:self.cache.nurse.oldName,
                                            linkNewNurseName:self.cache.nurse.newName,
                                            linkId:self.form.dialog.id,
                                            createTime:self.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss')
                                        }
                                        bloodSourcesHttp.insertXyLinkNurseUpdateListInfo(param).then(res=>{
                                            if(res.content){
                                                self.$message({
                                                    message: '护士配置信息同步成功！',
                                                    type: 'warning'
                                                }); 
                                            }else{
                                                self.$message({
                                                        message: '护士配置信息同步失败！',
                                                        type: 'warning'
                                                 }); 
                                            }
                                        });
                                }else{
                                    //相等，就什么也不做
                                }
                           }else{
                              this.$message({
                                  message: '编辑信息失败',
                                  type: 'warning'
                              }); 
                           }
                  });
          
          }else{
              self.form.dialog.linkProviderId = self.form.dialog.providerId;
              self.form.dialog.useNurseDeptId = self.form.dialog.nurse.deptId;//护士部门ID
              self.form.dialog.useNurseName = self.form.dialog.nurse.name;    //护士名称
              self.form.dialog.useNurseId = self.form.dialog.nurse.id;        //护士ID
            bloodSourcesHttp.xyLinkInsertOrUpdate(self.form.dialog).then(res=>{
                         if(res.content){
                             //进行form表单数据清空
                             self.clearFormData();
                             //关闭dialog
                             self.dialog.config.isShow = false;
                             //刷新外部表格数据，显示最新添加的血源链接数据
                             self.getInitTableXyList();
                         }else{
                            this.$message({
                                message: '该浆员已有链接信息',
                                type: 'warning'
                            }); 
                         }
                });
          }
      },
      //清除上次血源链接表单的数据，留一个干净的页面等待下次操作，提高交互性
      clearFormData(){
          let self = this;
          self.form.dialog.cardId = null;
          self.form.dialog.providerId = null;
          self.form.dialog.useNurseId = null;
          self.form.dialog.nurse = null;
          self.form.dialog.useNurseName = null;
          self.form.dialog.linkProviderName = null;
          self.form.dialog.address = null;
          self.form.dialog.useWeChart = "否";
          self.form.dialog.isPulpingMsg = "否";
          self.form.dialog.pulpingMsgType = "按提前天数提醒";
          self.form.dialog.advancePulpingMsgDays = "空";
          self.form.dialog.intervalPulpingMsgDays = "";
          self.form.dialog.activeLevel = "空";
          self.form.dialog.familyJoinPulping = "空";
          self.form.dialog.friendJoinPulping = "空";
          self.form.dialog.useVolunteeId = null;
          self.form.dialog.useVolunteeName = "空";
          self.form.dialog.useVolunteeTime = self.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss');
          self.form.dialog.createTime = self.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss');         
      }
  } 
}
//获取当前时间，格式YYYY-MM-DD
window.getNowFormatDate =function () {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate + " 00:00:00";
    return currentdate;
}
export default obj;
</script>
<style lang="stylus" scoped>
.mapContent 
  position relative
  .search 
    position absolute 
    top 0
    left 0
    z-index 1
  #chart
    position absolute
    top 0
    left 0
    width 100%
    height 100%
    z-index 0
</style>

 
 <style type="text/css" scoped>
    .cursor{
      cursor:pointer;
    }
    .cursor:hover{
      color:floralwhite;
      background-color:#436EEE;
    }
.table td > .placehold-communication,
.table td > div > .placehold-communication {
    display: none;
    width: 90px;
    position: absolute;
    left: 0px;
    top: 24px;
    color: #000;
    font-size: 13px;
    border: 1px solid rgba(51, 51, 51, 0.33);
    padding: 5px;
    line-height: 16px;
    background: #FFF;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-box-shadow: 0px 0px 15px 1px rgba(0, 0, 0, .55);
    -moz-box-shadow: 0px 0px 15px 1px rgba(0, 0, 0, .55);
    box-shadow: 0px 0px 15px 1px rgba(0, 0, 0, 0.55);
    border-radius: 7px;
    -webkit-border-radius: 7px;
    -moz-border-radius: 7px;
    z-index: 666;
    
}
.pulp-name-class{
    width:100%;
    height:13px;
    display:block;
    cursor:pointer;
    margin-bottom:2px;
}
.el-dialog__body{
    color:black !important;
}
.select_type_class{
    position: absolute;
    left:40%;
    top:5px;
    z-index:999;
}
h1{
    font-size:17px !important;
    font-weight:blod;
    position: absolute;
    left:20px;
    top:25px;
    }
 </style>

